﻿#ifndef JSON_HANDLE_H
#define JSON_HANDLE_H

#include <QObject>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QMap>
#include "json_allcommand.h"
#include "type_valuekey.h"

typedef QMap<QString, type_valueKey> shareMap;

class Json_handle : public QObject, public Json_AllCommand
{
    Q_OBJECT
public:
    explicit Json_handle(QObject *parent = 0);
    void jsontest();//json测试

    QString order_login(QString UserName, QString PassWord, QString CheckNum);//生成登陆命令
    int order_loginexplain(QString dataString);//解析登陆返回命令

    QString order_systemSetting(shareMap dataMap);//生成系统设置保存命令

    QString order_motionSetting(shareMap dataMap, bool enableFlag[]);//生成运动参数保存命令
    QString order_getMontionSetting();//生成运动参数请求命令
    QString order_getSytemSetting();//生成系统参数请求命令
    QString order_IODiagnose(int value, bool flag, QList<float> AOList);
    QString order_manualDiagnose(int num, bool stat, int backzero = 5);
    QString order_runningstatus();
    QString order_readyStatus();
    QString order_runContral(int num);
    QString order_jcodeString(QString filename, QStringList jcodeString);
//    QString order_takeDataString(QString);
    int order_crcexplain(QString resultString);//CRC校验
    int order_jcodeCrcexplain(QString resultString);
    int order_jcodeCrcexplain(QByteArray b);
    QString order_makeup(int Crc, int Fcs, QString DataString);//组装json包
    QMap<QString,QString> order_replyexplain(QString replyString);
    QStringList getJsonObjectNameString(QString dataString);

    enum contralOrder {
        Stop,
        Start,
        Pause,
        Reset
    };
signals:

public slots:

private:
    QJsonArray getBitJsonObject(bool flag, int flag2);

    QJsonObject json;
    QJsonDocument document;
};

#endif // JSON_HANDLE_H
